//取值
function Common_GetValue() {
    var itmValue = '';

    if (typeof(arguments[0]) !== 'string') return '';
    if (arguments[0] == '') return '';

    var $this = $('#'+ arguments[0]);
    if ($this.length < 1) return '';

    var className = $this.attr("class").split(' ')[0];

    if (className == 'textbox') {  //文本框
        itmValue = $this.val();
    }else if (className == 'hisui-numberbox') {  //数字
        itmValue = $this.val();
    }else if (className == 'hisui-datebox') {  //日期
        itmValue = $this.datebox('getValue');
    }else if (className == 'hisui-timespinner') {  //时间框
        itmValue = $this.timespinner('getValue');
    }else if (className == 'hisui-combobox') {  //下拉框（多选下拉框没有封装）
        itmValue = $this.combobox('getValue');
    }else if (className == 'hisui-switchbox') {  //开关
        itmValue = $this.switchbox('getValue');
    }else if (className == 'hisui-checkbox') {  // 单个复选框
        itmValue = $this.checkbox('getValue');
    }else if (className == 'hisui-radio') {  //单个单选框
        itmValue = $this.radio('getValue');
    }else if (className == 'hisui-searchbox') {  //查询框框
        itmValue = $this.searchbox('getValue');
    }

    return itmValue;
}

//取值
function Common_GetText() {
    var itmValue = '';

    if (typeof(arguments[0]) !== 'string') return '';
    if (arguments[0] == '') return '';

    var $this = $('#'+ arguments[0]);
    if ($this.length < 1) return '';

    var className = $this.attr("class").split(' ')[0];

    if (className == 'textbox') {  //文本框
        itmValue = $this.val();
    }else if (className == 'hisui-numberbox') {  //数字
        itmValue = $this.val();
    }else if (className == 'hisui-datebox') {  //日期
        itmValue = $this.datebox('getValue');
    }else if (className == 'hisui-timespinner') {  //时间框
        itmValue = $this.timespinner('getValue');
    }else if (className == 'hisui-combobox') {  //下拉框
        itmValue = $this.combobox('getText');
    }else if (className == 'hisui-switchbox') {  //开关
        itmValue = $this.switchbox('getValue');
    }else if (className == 'hisui-checkbox') {  // 单个复选框
        itmValue = $this.attr("label");
    }else if (className == 'hisui-radio') {  //单个单选框
        itmValue =$this.attr("label");
    }else if (className == 'hisui-searchbox') {  //查询框框
        itmValue = $this.searchbox('getValue');
    }

    return itmValue;
}

//赋值
function Common_SetValue() {
    var itmValue = '';

    var val = arguments[1];
    var txt = arguments[2];

    if (typeof(arguments[0]) !== 'string') return '';
    if (arguments[0] == '') return '';

    var $this = $('#'+ arguments[0]);
    if ($this.length < 1) return '';
    if (typeof val == 'undefined') val = '';
    if (typeof txt == 'undefined') txt = '';

    var className = $this.attr("class").split(' ')[0];

    if (className == 'textbox') {  //文本框
        itmValue = $this.val(val);
    }else if (className == 'hisui-numberbox') {  //数字
        itmValue = $this.val(val);
    }else if (className == 'hisui-datebox') {  //日期
        itmValue = $this.datebox('setValue',val);
    }else if (className == 'hisui-timespinner') {  //时间框
        itmValue = $this.timespinner('setValue',val);
    }else if (className == 'hisui-combobox') {  //下拉框
        if(val !="" && txt ==""){
            itmValue = $this.combobox('setValue',val);
        }else{
            itmValue = $this.combobox('setValue',txt);
        }
    }else if (className == 'hisui-switchbox') {  //开关
        itmValue = $this.switchbox('setValue',val);
    }else if (className == 'hisui-checkbox') {  // 单个复选框
        if (val == '') val = 0;
        itmValue = $this.checkbox('setValue',(val) ? true : false);
    }else if (className == 'hisui-radio') {  //单个单选框
        if (val == '') val = 0;
        itmValue = $this.radio('setValue',(val) ? true : false);
    }else if (className == 'hisui-searchbox') {  //查询框框
        itmValue = $this.searchbox('setValue',val);
    }

    return itmValue;
}

//根据病种生成准入/准出规则
function Common_CheckboxToSDRule() {
    var ItemCode = arguments[0];
    var ParRef	 = arguments[1];
    var RuleType = arguments[2];
    var columns	 = arguments[3]? arguments[3] : 4;;
    var params = {};
    var ajax = new $ax(Sys.backendPath + "/sds/sdsopqcincase/selectRulesByQcEntityId", function (data) {
        //加载表格数据
        var dicList = data.split(";");
        if (dicList[0]=="") {$('#'+ItemCode).html(""); return;}
        var len =dicList.length;
        var count = parseInt(len/columns)+1;
        var per = Math.round((1/columns) * 100) + '%';  //每列所在百分比，等比分布

        var listHtml=""
        for (var index =0; index< count; index++) {
            var chklen=(((index+1)*columns)<len) ? (index+1)*columns : len;
            listHtml +="<div>";
            for (var dicIndex = index*columns; dicIndex < chklen; dicIndex++) {
                var dicSubList = dicList[dicIndex].split(",");

                listHtml += "<div style='overflow: auto;float:left;width:"+per+"'><input id="+ItemCode+dicSubList[0]+" type='checkbox' class='hisui-checkbox' "+(dicSubList[0]==1? "checked='true'":"")+" label= '"+dicSubList[1]+"'  name="+ItemCode+"  value="+dicSubList[0]+"></div>";
            }
            listHtml +="</div>"
        }
        $('#'+ItemCode).html(listHtml);
        $.parser.parse('#'+ItemCode);  //解析checkbox
    }, function (data) {
    });
    params.qcEntityId = ParRef;
    params.ruleType = RuleType;
    ajax.set(params);
    ajax.start();
}

//多选字典取值 Common_CheckboxValue("chkStatusList")
function Common_CheckboxValue() {
    var ItemCode = arguments[0];
    var value = "";
    $("input[name='"+ItemCode+"']:checked").each(function(){
        value = value + $(this).val()+ ",";
    });
    if (value!="") { value = value.substring(0, value.length-1); }

    return value;
}
